package routes

import (
	"ginblog/api/v1"
	"ginblog/middleware"
	"ginblog/utils"
	"github.com/gin-gonic/gin"
)

// func initRouter 方法名称如果开头小写表明私有，大写表明公有
func InitRouter() {
	gin.SetMode(utils.GIN_MODE)
	r := gin.Default()

	auth := r.Group("api/v1")
	auth.Use(middleware.JwtToken())
	{
		//用户模块的路由接口


		auth.PUT("user/:id", v1.EditUser)
		auth.DELETE("user/:id", v1.DeleteUser)
		// 分类模块的路由接口
		auth.POST("category/add", v1.AddCategory)

		auth.PUT("category/:id", v1.EditCategory)
		auth.DELETE("category/:id", v1.DeleteCategory)
		// 分类模块的路由接口
		auth.POST("artical/add", v1.AddArtical)

		auth.PUT("artical/:id", v1.EditArtical)
		auth.DELETE("artical/:id", v1.DeleteArtical)
	}
	router := r.Group("api/v1")
	{
		router.POST("user/add", v1.AddUser)
		router.GET("users", v1.GetUsers)
		router.GET("artical", v1.GetArticals)
		router.GET("artical/list", v1.GetCateArt)
		router.GET("artical/info", v1.GetArtInfo)
		router.GET("category", v1.GetCategorys)
		router.POST("/login",v1.Login)
	}

	r.Run(utils.HttpPort)
}
